function webServiceBoleiaError(jqXHR, textStatus, errorThrown) {
    alert("Error: " + textStatus);
}

function getAllUsers(callback) {
    var url = "/Trabalho_PD/webresources/WebServiceBoleias/getAllUsers";
    $.ajax({
        type: "GET",
        dataType: "json",
        url: url,
        cache: false,
        success: function(data, textStatus, jqXHR){
            callback(data["users"]);
        },
        error: webServiceBoleiaError
    });
}

function getUser(user_id, callback) {
    var url = "/Trabalho_PD/webresources/WebServiceBoleias/getUser/" + user_id;
    $.ajax({
        type: "GET",
        dataType: "json",
        url: url,
        cache: false,
        success: function(data, textStatus, jqXHR){
            callback(data);
        },
        error: webServiceBoleiaError
    });
}

function getAllCountrys(callback) {
    var url = "/Trabalho_PD/webresources/WebServiceBoleias/getCountrys";
    $.ajax({
        type: "GET",
        dataType: "json",
        url: url,
        cache: false,
        success: function(data, textStatus, jqXHR){
            callback(data["country"]);
        },
        error: webServiceBoleiaError
    });
}

function getAllAdressFromCountry(countryId, callback) {
    var url = "/Trabalho_PD/webresources/WebServiceBoleias/getAllAddressFromCountry/"+countryId;
    $.ajax({
        type: "GET",
        dataType: "json",
        url: url,
        cache: false,
        success: function(data, textStatus, jqXHR){
            callback(data["address"]);
        },
        error: webServiceBoleiaError
    });
}

function getAllAddress(callback) {
    var url = "/Trabalho_PD/webresources/WebServiceBoleias/getAllAddress";
    $.ajax({
        type: "GET",
        dataType: "json",
        url: url,
        cache: false,
        success: function(data, textStatus, jqXHR){
            callback(data["address"]);
        },
        error: webServiceBoleiaError
    });
}

function getCar(car_id, callback) {
    var url = "/Trabalho_PD/webresources/WebServiceBoleias/getCar/" + car_id;
    $.ajax({
        type: "GET",
        dataType: "json",
        url: url,
        cache: false,
        success: function(data, textStatus, jqXHR){
            callback(data);
        },
        error: webServiceBoleiaError
    });
}

function getAllTripsFromCar(car_id, callback) {
    var url = "/Trabalho_PD/webresources/WebServiceBoleias/getAllTripsFromCar/" + car_id;
    $.ajax({
        type: "GET",
        dataType: "json",
        url: url,
        cache: false,
        success: function(data, textStatus, jqXHR){
            callback(data["trips"]);
        },
        error: webServiceBoleiaError
    });
}